#include <iostream>
using namespace std;
void menu()
{
	cout<<"******************************"<<endl;
	cout<<"******* 1. Add  2. Miu *******"<<endl;
	cout<<"******* 3. Mul  4. Div *******"<<endl;
	cout<<"********** 0. exit  **********"<<endl;
	cout<<"******************************"<<endl;
	
}
int Add(int x,int y);
int Miu(int x,int y);
int Mul(int x,int y);
int Div(int x,int y);
//void cala(int (*pf)(int ,int))
//{
//	int ret = 0;
//	int a,b;
//	cout<<"请输入两个操作数->";
//    cin>>a>>b;
//    ret = pf(a,b);
//    cout<<ret<<endl;
//}
int main ()
{
    int input = 0;
	int a = 0;
	int b = 0;
    int ret = 0;
    int (*parr[])(int ,int) = {0,Add,Miu,Mul,Div};
	//函数指针数组可以更加方便的选择调用多个函数可以代替部分switch的情况。
    do
    {
    menu();
    cout<<"请选择->";
    cin>>input;
    if(input == 0)
    {
    	cout<<"程序结束。"<<endl; 
	}
	else if(input >= 1 && input <= 4)
	{
	
	cout<<"请输入两个操作数->";
    cin>>a>>b;
    ret = parr[input](a,b);
    cout<<ret<<endl;
	}
	else
	{
		cout<<"输入错误。"<<endl; 
	}
	}while(input);
	return 0;
}
int Add(int x,int y)
{
	return x + y;
}
int Miu(int x,int y)
{
	return x - y;
}
int Mul(int x,int y)
{
	return x * y;
}
int Div(int x,int y)
{
	return x / y;
}
